home *** CD-ROM | disk | FTP | other *** search
/ Freelog 121 / FreelogMagazineJuilletAout2014-No121.iso / Outils / Adobe-Air / adobe-air_13.exe / [0] / setup.swf / scripts / mx / containers / GridRow.as < prev    next >
Text File  |  2014-03-27  |  9KB  |  246 lines

  1. package mx.containers
  2. {
  3.    import flash.display.DisplayObject;
  4.    import mx.containers.gridClasses.GridColumnInfo;
  5.    import mx.containers.gridClasses.GridRowInfo;
  6.    import mx.containers.utilityClasses.Flex;
  7.    import mx.core.EdgeMetrics;
  8.    import mx.core.ScrollPolicy;
  9.    import mx.core.mx_internal;
  10.    
  11.    use namespace mx_internal;
  12.    
  13.    public class GridRow extends HBox
  14.    {
  15.       
  16.       mx_internal static const VERSION:String = "3.0.0.0";
  17.        
  18.       
  19.       var rowIndex:int = 0;
  20.       
  21.       var columnWidths:Array;
  22.       
  23.       var rowHeights:Array;
  24.       
  25.       var numGridItems:int;
  26.       
  27.       public function GridRow()
  28.       {
  29.          super();
  30.          super.clipContent = false;
  31.       }
  32.       
  33.       override public function getStyle(param1:String) : *
  34.       {
  35.          return param1 == "horizontalGap" && parent ? Grid(parent).getStyle("horizontalGap") : super.getStyle(param1);
  36.       }
  37.       
  38.       override public function invalidateDisplayList() : void
  39.       {
  40.          super.invalidateDisplayList();
  41.          if(parent)
  42.          {
  43.             Grid(parent).invalidateDisplayList();
  44.          }
  45.       }
  46.       
  47.       override public function get clipContent() : Boolean
  48.       {
  49.          return false;
  50.       }
  51.       
  52.       override public function set horizontalScrollPolicy(param1:String) : void
  53.       {
  54.       }
  55.       
  56.       override public function set clipContent(param1:Boolean) : void
  57.       {
  58.       }
  59.       
  60.       function doRowLayout(param1:Number, param2:Number) : void
  61.       {
  62.          var _loc8_:GridItem = null;
  63.          var _loc9_:int = 0;
  64.          var _loc10_:Number = NaN;
  65.          var _loc11_:Number = NaN;
  66.          var _loc12_:Number = NaN;
  67.          var _loc13_:int = 0;
  68.          var _loc14_:GridColumnInfo = null;
  69.          var _loc15_:Number = NaN;
  70.          var _loc16_:int = 0;
  71.          var _loc17_:GridRowInfo = null;
  72.          var _loc18_:Number = NaN;
  73.          var _loc19_:Number = NaN;
  74.          layoutChrome(param1,param2);
  75.          var _loc3_:Number = numChildren;
  76.          if(_loc3_ == 0)
  77.          {
  78.             return;
  79.          }
  80.          var _loc4_:Boolean = mx_internal::invalidateSizeFlag;
  81.          var _loc5_:Boolean = mx_internal::invalidateDisplayListFlag;
  82.          invalidateSizeFlag = true;
  83.          invalidateDisplayListFlag = true;
  84.          if(parent.getChildIndex(this) == 0 || isNaN(columnWidths[0].x) || columnWidths.minWidth != minWidth || columnWidths.maxWidth != maxWidth || columnWidths.preferredWidth != getExplicitOrMeasuredWidth() || columnWidths.percentWidth != percentWidth || columnWidths.width != param1 || columnWidths.paddingLeft != getStyle("paddingLeft") || columnWidths.paddingRight != getStyle("paddingRight") || columnWidths.horizontalAlign != getStyle("horizontalAlign") || columnWidths.borderStyle != getStyle("borderStyle"))
  85.          {
  86.             calculateColumnWidths();
  87.             columnWidths.minWidth = minWidth;
  88.             columnWidths.maxWidth = maxWidth;
  89.             columnWidths.preferredWidth = getExplicitOrMeasuredWidth();
  90.             columnWidths.percentWidth = percentWidth;
  91.             columnWidths.width = param1;
  92.             columnWidths.paddingLeft = getStyle("paddingLeft");
  93.             columnWidths.paddingRight = getStyle("paddingRight");
  94.             columnWidths.horizontalAlign = getStyle("horizontalAlign");
  95.             columnWidths.borderStyle = getStyle("borderStyle");
  96.          }
  97.          var _loc6_:EdgeMetrics = viewMetricsAndPadding;
  98.          var _loc7_:int = 0;
  99.          while(_loc7_ < _loc3_)
  100.          {
  101.             _loc9_ = (_loc8_ = GridItem(getChildAt(_loc7_))).colIndex;
  102.             _loc10_ = columnWidths[_loc9_].x;
  103.             _loc11_ = _loc6_.top;
  104.             _loc12_ = _loc8_.percentHeight;
  105.             _loc13_ = Math.min(_loc9_ + _loc8_.colSpan,columnWidths.length);
  106.             _loc15_ = (_loc14_ = columnWidths[_loc13_ - 1]).x + _loc14_.width - _loc10_;
  107.             _loc16_ = Math.min(rowIndex + _loc8_.rowSpan,rowHeights.length);
  108.             _loc18_ = (_loc17_ = rowHeights[_loc16_ - 1]).y + _loc17_.height - rowHeights[rowIndex].y - _loc6_.top - _loc6_.bottom;
  109.             if((_loc19_ = _loc15_ - _loc8_.maxWidth) > 0)
  110.             {
  111.                _loc10_ += _loc19_ * mx_internal::layoutObject.getHorizontalAlignValue();
  112.                _loc15_ -= _loc19_;
  113.             }
  114.             _loc19_ = _loc18_ - _loc8_.maxHeight;
  115.             if(_loc12_ && _loc12_ < 100)
  116.             {
  117.                _loc19_ = Math.max(_loc19_,_loc18_ * (100 - _loc12_));
  118.             }
  119.             if(_loc19_ > 0)
  120.             {
  121.                _loc11_ = _loc19_ * mx_internal::layoutObject.getVerticalAlignValue();
  122.                _loc18_ -= _loc19_;
  123.             }
  124.             _loc15_ = Math.ceil(_loc15_);
  125.             _loc18_ = Math.ceil(_loc18_);
  126.             _loc8_.move(_loc10_,_loc11_);
  127.             _loc8_.setActualSize(_loc15_,_loc18_);
  128.             _loc7_++;
  129.          }
  130.          invalidateSizeFlag = _loc4_;
  131.          invalidateDisplayListFlag = _loc5_;
  132.       }
  133.       
  134.       private function calculateColumnWidths() : void
  135.       {
  136.          var _loc5_:Number = NaN;
  137.          var _loc6_:GridColumnInfo = null;
  138.          var _loc7_:Number = NaN;
  139.          var _loc8_:int = 0;
  140.          var _loc11_:Number = NaN;
  141.          var _loc12_:Number = NaN;
  142.          var _loc13_:int = 0;
  143.          var _loc1_:EdgeMetrics = viewMetricsAndPadding;
  144.          var _loc2_:Number = getStyle("horizontalGap");
  145.          var _loc3_:int = columnWidths.length;
  146.          var _loc4_:Number = unscaledWidth - _loc1_.left - _loc1_.right - (_loc3_ - 1) * _loc2_;
  147.          var _loc9_:Number = 0;
  148.          var _loc10_:Array = [];
  149.          _loc5_ = _loc4_;
  150.          _loc8_ = 0;
  151.          while(_loc8_ < _loc3_)
  152.          {
  153.             if(_loc11_ = (_loc6_ = columnWidths[_loc8_]).percent)
  154.             {
  155.                _loc9_ += _loc11_;
  156.                _loc10_.push(_loc6_);
  157.             }
  158.             else
  159.             {
  160.                _loc12_ = _loc6_.width = _loc6_.preferred;
  161.                _loc5_ -= _loc12_;
  162.             }
  163.             _loc8_++;
  164.          }
  165.          if(_loc9_)
  166.          {
  167.             _loc5_ = Flex.flexChildrenProportionally(_loc4_,_loc5_,_loc9_,_loc10_);
  168.             _loc13_ = _loc10_.length;
  169.             _loc8_ = 0;
  170.             while(_loc8_ < _loc13_)
  171.             {
  172.                _loc6_ = _loc10_[_loc8_];
  173.                _loc6_.width = _loc6_.size;
  174.                _loc8_++;
  175.             }
  176.          }
  177.          _loc7_ = _loc1_.left + _loc5_ * mx_internal::layoutObject.getHorizontalAlignValue();
  178.          _loc8_ = 0;
  179.          while(_loc8_ < _loc3_)
  180.          {
  181.             (_loc6_ = columnWidths[_loc8_]).x = _loc7_;
  182.             _loc7_ += _loc6_.width + _loc2_;
  183.             _loc8_++;
  184.          }
  185.       }
  186.       
  187.       override public function get horizontalScrollPolicy() : String
  188.       {
  189.          return ScrollPolicy.OFF;
  190.       }
  191.       
  192.       override public function invalidateSize() : void
  193.       {
  194.          super.invalidateSize();
  195.          if(parent)
  196.          {
  197.             Grid(parent).invalidateSize();
  198.          }
  199.       }
  200.       
  201.       function updateRowMeasurements() : void
  202.       {
  203.          var _loc6_:Number = NaN;
  204.          var _loc8_:GridColumnInfo = null;
  205.          var _loc1_:Number = columnWidths.length;
  206.          var _loc2_:Number = 0;
  207.          var _loc3_:Number = 0;
  208.          var _loc4_:int = 0;
  209.          while(_loc4_ < _loc1_)
  210.          {
  211.             _loc8_ = columnWidths[_loc4_];
  212.             _loc2_ += _loc8_.min;
  213.             _loc3_ += _loc8_.preferred;
  214.             _loc4_++;
  215.          }
  216.          var _loc5_:Number = mx_internal::layoutObject.widthPadding(_loc1_);
  217.          _loc6_ = mx_internal::layoutObject.heightPadding(0);
  218.          var _loc7_:GridRowInfo = rowHeights[rowIndex];
  219.          measuredMinWidth = _loc2_ + _loc5_;
  220.          measuredMinHeight = _loc7_.min + _loc6_;
  221.          measuredWidth = _loc3_ + _loc5_;
  222.          measuredHeight = _loc7_.preferred + _loc6_;
  223.       }
  224.       
  225.       override public function set verticalScrollPolicy(param1:String) : void
  226.       {
  227.       }
  228.       
  229.       override public function get verticalScrollPolicy() : String
  230.       {
  231.          return ScrollPolicy.OFF;
  232.       }
  233.       
  234.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  235.       {
  236.       }
  237.       
  238.       override public function setChildIndex(param1:DisplayObject, param2:int) : void
  239.       {
  240.          super.setChildIndex(param1,param2);
  241.          Grid(parent).invalidateSize();
  242.          Grid(parent).invalidateDisplayList();
  243.       }
  244.    }
  245. }
  246.